TableViewExample
by Mai Nguyen, NeXT Developer Support Team

Overview

In order to run this example, you need to have a Sybase server with a pubs database installed. This example uses the SybaseDemo.dbmodela model file (also available under /NextDeveloper/Examples/DatabaseKit/Models).
For Oracle users, you can modify the TableViewController.m file to comment out  #define SYBASE_DEMO  and recompile the application.

This example shows how you can define a DBTableView and a DBModule programmatically instead of using the corresponding Interface Builder UI Objects .  It also shows how you can change the sort order every time the columns in the tableview are rearranged. The sort property is determined by the identifiers of the tableview columns.

Program Organization

Major Classes in the Application

TableViewController	A general manager object.  A subclass of the Object class.  Performs miscellaneous 		initialzations for the DBModule and DBTableView objects. 

Other Peculiarities
In order to load an Adaptor dynamically, you need to add the OTHER_LDFLAGS definition (see the Makefile.preamble). You also need to add the libdbkit_s.a library into your PB.project under libraries in order to use the DBKit API. 

Topics Of Interest

- How to get all the attributes from an entity and the sub-attributes that belongs to a one-to-one relationship of
  that same entity 
See the method initTableView: in the file TableViewController.m.

- How to make a fetchgroup become the datasource of the tableview by using the method 
   makeAssociationFrom:
See the method initTableView: in the file TableViewController.m

- How to replicate the IB connections to a tableview by using DBExpressions
See the method  addTableColumn in the file TableViewController.m

Change History
February 1993		Updated for 3.1